/**
 * Copyright 2005 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.edi.runtime.Event
{
	import mx.controls.dataGridClasses.DataGridColumn;
	import mx.core.UIComponent;
	
	/**
	 * 数据分发代理 
	 * 
	 */	
	public class EDIEventProxy
	{
		private static var _dataLoadList:Array=new Array;
		private static var _dataRollingList:Array=new Array;
		
		/**
		 * 注册需要监听数据加载的对象 
		 * @param tableName
		 * @param edi
		 * 
		 */		
		public static function listenerDataLoad(tableName:String,edi:Object):void
		{
			var obj:Object=new Object();
			obj["tableName"]=tableName;
			obj["edi"]=edi;
			_dataLoadList.push(obj);
		}
		
		/**
		 * 注册需要监听数据滚动的对象 
		 * @param tableName
		 * @param edi
		 * 
		 */		
		public static function listenerDataRolling(tableName:String,edi:Object):void
		{
			var obj:Object=new Object();
			obj["tableName"]=tableName;
			obj["edi"]=edi;
			_dataRollingList.push(obj);
		}
		
		/**
		 * 然会所有需要监听数据加载的对象集合 
		 * @return 
		 * 
		 */		
		public static function get dataLoadList():Array
		{
			return _dataLoadList;
		}
		
		/**
		 *  然会所有需要监听数据滚动的对象集合 
		 * @return 
		 * 
		 */		
		public static function get dataRollingList():Array
		{
			return _dataRollingList;
		}
		
		/**
		 * 移除
		 * @param parentDocument
		 * 
		 */		
		public static function removeListener(parentDocument:Object):void
		{
			var i:int;
			for(i=_dataLoadList.length-1;i>-1;i--)
			{
				if((_dataLoadList[i]["edi"] as UIComponent).parentDocument==parentDocument)
				{
					_dataLoadList[i]["edi"]=null
					_dataLoadList.splice(i,1);
				}
			}
			
			for(i=_dataRollingList.length-1;i>-1;i--)
			{
				if(_dataRollingList[i]["edi"] is UIComponent)
				{
					if((_dataRollingList[i]["edi"] as UIComponent).parentDocument==parentDocument)
					{
						_dataRollingList[i]["edi"]=null
						_dataRollingList.splice(i,1);
					}
				}
			}
		}
		
	}
}